import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useModalStore = defineStore('modal', () => {
  // 状态
  const showImportModal = ref(false)
  const showAreaModal = ref(false)
  const showClearCanvasModal = ref(false)
  const showInputPointModal = ref(false)

  // 动作
  const openImportModal = () => {
    showImportModal.value = true
  }

  const closeImportModal = () => {
    showImportModal.value = false
  }

  const openAreaModal = () => {
    showAreaModal.value = true
  }

  const closeAreaModal = () => {
    showAreaModal.value = false
  }

  const openClearCanvasModal = () => {
    showClearCanvasModal.value = true
  }

  const closeClearCanvasModal = () => {
    showClearCanvasModal.value = false
  }

  const openInputPointModal = () => {
    showInputPointModal.value = true
  }

  const closeInputPointModal = () => {
    showInputPointModal.value = false
  }

  const toggleInputPointModal = () => {
    showInputPointModal.value = !showInputPointModal.value
  }

  const closeAllModals = () => {
    showImportModal.value = false
    showAreaModal.value = false
    showClearCanvasModal.value = false
    showInputPointModal.value = false
  }

  return {
    // 状态
    showImportModal,
    showAreaModal,
    showClearCanvasModal,
    showInputPointModal,
    // 动作
    openImportModal,
    closeImportModal,
    openAreaModal,
    closeAreaModal,
    openClearCanvasModal,
    closeClearCanvasModal,
    openInputPointModal,
    closeInputPointModal,
    toggleInputPointModal,
    closeAllModals
  }
})
